#
# @lc app=leetcode.cn id=7 lang=python3
#
# [7] 整数反转
#


# @lc code=start
class Solution:
    def reverse(self, x: int) -> int:
        if x > 0:
            x = list(str(x))
            x.reverse()
            x = int(''.join(x))
            if x <= 2**31 - 1:
                return x
            else:
                return 0
        elif x < 0:
            x = list(str(-x))
            x.reverse()
            x = -int(''.join(x))
            if x >= -2**31:
                return x

            else:
                return 0
        else:
            return 0


# @lc code=end
